package stream流;

import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;

public class testdome1 {
    public static void main(String[] args) {
        ArrayList<Integer> list1 = new ArrayList<>();
        ArrayList<Integer> list2 = new ArrayList<>();
        Collections.addAll(list1,1,2,3,4,5,6,7,8,9,10);
        Collections.addAll(list2,10,11,12,34,23);
        //大于5的元素
        /*list1.stream().filter(s -> s >=5).forEach(s -> System.out.println(s));
        //取数组的前三个数
        list1.stream().limit(3).forEach(s -> System.out.println(s));*/
        //跳过前三个元素，取后面的元素
        //list1.stream().skip(3).forEach(s -> System.out.println(s));

        Stream<Integer> s1 = list1.stream();
        Stream<Integer> s2 = list2.stream();
        //合并并去重
        Stream.concat(s1, s2).distinct().forEach(s -> System.out.print(s + " "));

    }
}
